package com.zm.scsimple.circuit.breaker.client;

import com.netflix.hystrix.HystrixCommandGroupKey;
import com.netflix.hystrix.contrib.javanica.annotation.HystrixCommand;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import org.springframework.web.client.RestTemplate;

/**
 * @author zoum
 * @create 2019/2/22 15:21
 */
@Component
public class ProfileService1 extends com.netflix.hystrix.HystrixCommand<String>{

    @Autowired
    private RestTemplate restTemplate;

    public ProfileService1(){
        super(HystrixCommandGroupKey.Factory.asKey("profile"));
    }

    @Override
    protected String getFallback() {
        return "default1";
    }

    @Override
    protected String run() throws Exception {
        return restTemplate.getForObject("http://localhost:8889/profile", String.class);
    }

}
